home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 August: Tool Chest / Dev.CD Aug 95 TC / Dev.CD Aug 95 TC.toast / New System Software Extensions / QuickDraw™ GX 1.1.2 / Programming Stuff / Sample Code / Printing Samples / Printer Drivers… / CustomWriter GX 1.0.3 ƒ / CommonDefines.h < prev    next >
Encoding:
Text File  |  1995-06-20  |  5.8 KB  |  180 lines  |  [TEXT/MPS ]

  1. /*
  2.     FILENAME
  3.         CommonDefines.h
  4.  
  5.     DESCRIPTION
  6.         Contains defines and prototypes used by more than one .r or .h file.
  7.  
  8.     COPYRIGHT
  9.         Copyright © 1995 Apple Computer, Inc.
  10.         All rights reserved.
  11.     
  12.     Modification history
  13.         06/14/95 - Dave Hersey -    Version 1.0.3 to fix a bug in
  14.                                     CustomBufferingAndIO.c when creating
  15.                                     high-res PICTs, and to make the size
  16.                                     of buffers more flexible.
  17.  
  18.         05/26/95 - Dave Hersey -    Version 1.0.2 to add the new 'outp'
  19.                                     desktop printer resource in NewApp.c.
  20.  
  21.         05/03/95 - Dave Hersey -    Version 1.0.1 to fix some minor bugs in
  22.                                     CustomBufferingAndIO.c.
  23.  
  24.         01/14/95 - Dave Hersey -    Created from the shell of a hollowed-out
  25.                                     ImageWriter driver.
  26.  
  27.     NOTE: Relevant goodies are listed in MPW's "Mark" menu.
  28.  
  29. */
  30.  
  31. // Driver info
  32. #define DriverName        "CustomWriter GX"
  33. #define DriverCreator     'cuWR'
  34. #define DriverType         'pdvr'
  35.  
  36. // Code segment info-- all driver overrides go in 'pdvr' resources;
  37. // these are the IDs we use for ours.
  38. #define NewSegID        0
  39. #define OldSegID        1
  40.  
  41. // The creator and type of the files we create.  (SimpleText PICTs)
  42. #define kFileCreator    'ttxt'
  43. #define kFileType        'PICT'
  44.  
  45. // Status defines
  46. #define kTransmissionStatID        gxPrintingDriverBaseID    // stat resource ID
  47. #define kSendingPartStatIdx        1    // item number for sending data
  48. #define kPreparingPartStatIdx    2    // item number for preparing data
  49. #define kPrintingPageStatIdx    3    // item number for writing page
  50.  
  51. // Chooser initialize message selector (wasn't in pre-ETO 16 headers).
  52. #define initializeMsg    11
  53.  
  54. // Resource ID for icon that we show in the Chooser's device list.
  55. #define r_ChooserIcon    (gxPrintingDriverBaseID +600)
  56.  
  57. // The number of our custom buffers, and percentage of free RAM they should use.
  58. #define kNumBuffs            (4)
  59. #define kBuffRAMPercentage    (30)
  60.  
  61. // The maximum amount of RAM we should gobble up for buffers.
  62.  
  63. #define kMaxRAMToUse    (2000 * 1024)
  64.  
  65. // Defines used by the old-application compatibility code.
  66. #define kPortrait            (0x04)
  67. #define kPrintRecordVers    (12)
  68. #define kDriverWDev            (0x8800)
  69.  
  70. // do the following only if we aren't running in Rez
  71. #ifndef REZ
  72.  
  73. #include <Devices.h>
  74. #include <Errors.h>
  75. #include <FixMath.h>
  76. #include <Folders.h>
  77. #include <Font Library.h>
  78. #include <Fonts.h>
  79. #include <Graphics Libraries.h>
  80. #include <Graphics Routines.h>
  81. #include <GXExceptions.h>
  82. #include <Layout Routines.h>
  83. #include <Lists.h>
  84. #include <LowMem.h>
  85. #include <Memory.h>
  86. #include <PrintingDrivers.h>
  87. #include <PrintingLibraries.h>
  88. #include <PrintingManager.h>
  89. #include <PrintingMessages.h>
  90. #include <Math Routines.h>
  91. #include <Math Types.h>
  92. #include <QuickDraw.h>
  93. #include <Resources.h>
  94. #include <Script.h>
  95. #include <StandardFile.h>
  96. #include <ToolUtils.h>
  97. #include <Types.h>
  98.  
  99. // Our global data structure
  100.  
  101. typedef struct
  102. {
  103.     long        lineFeeds;                // accumulated lines feeds
  104.     FSSpec        fileLocation;            // Where to put our files.
  105.     short        curFileRefNum;            // refNum of current open file.
  106.     long        pagesImaged;            // Number of pages imaged.
  107.     long        lastYPos;                // Used by our RasterDatIn override.
  108.     Rect        pixMapBounds;            // Bounds of the pixmap we create.
  109.     short        pixMapRowBytes;            // rowBytes of the pixmap we create.
  110.     Fixed        hRes;                    // Horizontal output resolution.
  111.     Fixed        vRes;                    // Vertical output resolution.
  112. } DriverGlobals, *DriverGlobalsPtr, **DriverGlobalsHdl;
  113.  
  114.  
  115. // Our buffer description
  116.  
  117. typedef struct
  118. {
  119.     Boolean                bufferIsDirty;                // Is this buffer dirty (is there data to be written out)?
  120.     char                padByte;
  121.     long                curOffset;                    // where's the next byte go in this buffer?
  122.     gxPrintingBuffer    **printBuffer;                // The buffers themselves.
  123. } BufferEntry, *BufferEntryPtr, **BufferEntryHdl;
  124.  
  125.  
  126. // our buffer group description-- a collection of BufferEntry records plus info.
  127.  
  128. typedef struct
  129. {
  130.     short        numBuffers;                // number of buffers
  131.     long        bufferSize;                // and their sizes.
  132.     short        curBuff;                // current buffer we're writing to.
  133.     BufferEntry    buff[1];                // individual buffer records.
  134. } BufferGroup, *BufferGroupPtr, **BufferGroupHdl;
  135.  
  136.  
  137. // Routines to save and retrieve our jump table globals.  These
  138. // routines are in NewApp.a
  139.  
  140. extern void SetDriverGlobals(DriverGlobalsHdl theGlobals);
  141. extern DriverGlobalsHdl GetDriverGlobals(void);
  142.  
  143. // Our prototypes in alphabetical order.
  144.  
  145. OSErr            CreateAndStoreGlobals(DriverGlobalsHdl *driverGlobalsHdl);
  146. OSErr            CreateBuffers(void);
  147. pascal OSErr    Device(short message, short caller, StringPtr objName, 
  148.                        StringPtr zoneName, ListHandle theList, long p2);
  149. OSErr            DisposeBuffers(void);
  150. void            DisposeGlobals(void);
  151. OSErr            FlushBuffers(BufferGroupHdl buffGrpHdl);
  152. pascal void        LDEF(short message, Boolean select, Rect *theRect,
  153.                      Cell theCell, short dataOffset, short dataLen, ListHandle theList);
  154. OSErr            SD_BufferData(Ptr data, long length, long bufferOptions);
  155. OSErr            SD_ChooserMessage(short message, short caller, StringPtr objName,
  156.                                   StringPtr zoneName, ListHandle theList, long p2);
  157. void            SD_CleanupOpenConnection(void);
  158. OSErr            SD_CloseConnection(void);
  159. OSErr            SD_ConvertPrintRecordFrom(gxUniversalPrintRecordHdl huPrint);
  160. OSErr            SD_ConvertPrintRecordTo(THPrint hoPrint);
  161. OSErr            SD_DefaultDesktopPrinter(Str31 dtpName);
  162. OSErr            SD_DumpBuffer(gxPrintingBuffer *theBuffer);
  163. OSErr            SD_FinishSendPage(void);
  164. OSErr            SD_FreeBuffer(gxPrintingBuffer *theBuffer);
  165. OSErr            SD_ImageJob(gxSpoolFile theSpoolFile, long *closeOptions);
  166. OSErr            SD_OpenConnection(void);
  167. OSErr            SD_PrValidate(THPrint hPrint, Boolean *wasChanged);
  168. OSErr            SD_RasterDataIn (gxOffscreenHdl hOffscreen, gxRectangle *bandRect, gxRectangle *dirtyRect);
  169. OSErr            SD_SetupImageData(gxRasterImageDataHdl hImageData);
  170. OSErr            SD_StartSendPage(gxFormat pageFormat);
  171. OSErr            SD_WriteData(Ptr data, long length);
  172. OSErr            UpdatePrintRecord(THPrint hPrint);
  173. OSErr            WriteBlankLines(long numBlankLinesToDo, gxRectangle *bandRect);
  174. OSErr            WriteEndOfPICTFile(void);
  175. OSErr            WriteStartOfPICTFile(void);
  176. OSErr            WriteRawData(void *dataBuffer, long dataLength);
  177.  
  178. #endif REZ
  179.  
  180.